<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

//Route::middleware('auth:api')->get('/user', function (Request $request) {
//    return $request->user();
//});

$api = app('Dingo\Api\Routing\Router');

$api->version('v1', [
    'namespace' => 'App\Http\Controllers\Api\V1',
], function ($api) {
    // 游客可以访问的接口
    // 短信验证码
    $api->post('verificationCodes', 'VerificationCodesController@store')->name('api.verificationCodes.store');
    // 用户注册
    $api->post('users', 'UsersController@store')->name('api.users.store');
    // 图片验证码
    $api->post('captchas', 'CaptchasController@store')->name('api.captchas.store');
    // 第三方登录
    $api->post('socials/{social_type}/authorizations', 'AuthorizationsController@socialStore')->name('api.socials.authorizations.store');
    // 登录
    $api->post('authorizations', 'AuthorizationsController@store')->name('api.authorizations.store');
    // 刷新token
    $api->put('authorizations/current', 'AuthorizationsController@update')->name('api.authorizations.update');
    // 删除token
    $api->delete('authorizations/current', 'AuthorizationsController@destroy')->name('api.authorizations.destroy');

    /*// 获取栏目导航
    $api->get('navigation/{navigation_type}', 'NavigationController@index')->name('api.navigation.index');
    // 获取文章列表(包含内容)
    $api->get('articles/{category_id}', 'ArticleController@index')->name('api.article.index');
    // 获取单页面内容
    $api->get('pages/{page_id}', 'PageController@show')->name('api.page.show');
    // 获取关于我们内容
    $api->get('about', 'PageController@about')->name('api.page.about');
    // 获取区块内容
    $api->get('blocks/{block_id}', 'BlockController@show')->name('api.block.show');*/

    $api->any('game/ebet/login', 'Game\EbetController@login')->name('ebet.login');
    $api->get('game/sc/login', 'Game\ScController@login')->name('sc.login');
    $api->get('game/sc/recharge', 'Game\ScController@recharge')->name('sc.recharge');

    $api->group(['prefix' => 'game'], function ($api) {
        $api->any('createMember', 'GameController@createMember')->name('game.createMember');        // 创建账号
        $api->any('getBalance', 'GameController@getBalance')->name('game.getBalance');              // 查询余额
        $api->any('transferIn', 'GameController@transferIn')->name('game.transferIn');              // 转入游戏
        $api->any('transferTo', 'GameController@transferTo')->name('game.transferTo');              // 转出游戏
        $api->any('checkTransfer', 'GameController@checkTransfer')->name('game.checkTransfer');     // 检查订单状态
        $api->any('kick', 'GameController@kick')->name('game.kick');                                // 踢线
        $api->any('joinGame', 'GameController@joinGame')->name('game.joinGame');                    // 进入游戏(pc端)
        $api->any('joinMobileGame', 'GameController@joinMobileGame')->name('game.joinMobileGame');  // 进入游戏（手机端）
        $api->any('getRecord', 'GameController@getRecord')->name('game.getRecord');                 // 获取数据
        $api->any('lotteryCode', 'GameController@lotteryCode')->name('game.lotteryCode');                 // 获取彩票列表
        $api->any('gameList', 'GameController@gameList')->name('game.gameList');                 // 获取游戏列表
        $api->any('oddsHandicap', 'GameController@oddsHandicap')->name('game.oddsHandicap');                 // 获取赔率盘口列表
        $api->any('quotaHandicap', 'GameController@quotaHandicap')->name('game.quotaHandicap');                 // 获取限额盘口列表
        $api->any('gameInfo', 'GameController@gameInfo')->name('game.gameInfo');                 // 获取游戏详情
        $api->any('platList', 'GameController@platList')->name('game.platList');                 // 获取平台列表
        $api->any('platGameList', 'GameController@platGameList')->name('game.platGameList');                 // 获取平台游戏列表

    }
    );


    // 需要 token 验证的接口
    $api->group(['middleware' => 'api.auth'], function ($api) {
        // 当前登录用户信息
        $api->get('user', 'UsersController@me')->name('api.user.show');
        // 当前登录用户权限
        $api->get('user/permissions', 'PermissionsController@index')->name('api.user.permissions.index');
        // ...

    }
    );


    $api->get('version', function () {
        return response('this is version v1');
    }
    );
}
);


